package com.wangtao.nio;


import java.nio.ByteBuffer;
import java.util.stream.IntStream;

public class ReadOnlyBuffer {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(64);

        IntStream.rangeClosed(0,63).forEach(i->{
            buffer.put((byte) i);
        });

        buffer.flip();

        ByteBuffer readOnlyBuffer = buffer.asReadOnlyBuffer();
        System.out.println(readOnlyBuffer.getClass());

        while (readOnlyBuffer.hasRemaining()) {
            System.out.println(readOnlyBuffer.get());
        }

        readOnlyBuffer.put((byte) 100);

    }
}
